using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Konst3d.Efficiency
{
    public struct ShortDate
	{
		#region Public Fields

		public int  Year;
        public byte Month;
        public byte Day;

		#endregion // Public Fields

		#region Constructors

		public ShortDate(int year, byte month, byte day)
        {
            Year = year;
            Month = month;
            Day = day;
        }

        public ShortDate(DateTime date)
        {
            Year = date.Year;
            Month = (byte)date.Month;
            Day = (byte)date.Day;
        }

		#endregion // Constructors

		#region Operators

		public static bool operator ==(ShortDate left, ShortDate right)
		{
			return left.Year == right.Year && left.Month == right.Month && left.Day == right.Day;
		}

		public static bool operator !=(ShortDate left, ShortDate right)
		{
			return left.Year != right.Year || left.Month != right.Month || left.Day != right.Day;
		}

		public static bool operator >(ShortDate left, ShortDate right)
		{
			if (left.Year != right.Year)
			{
				return left.Year > right.Year;
			}

			if (left.Month != right.Month)
			{
				return left.Month > right.Month;
			}

			return left.Day > right.Day;
		}

		public static bool operator >=(ShortDate left, ShortDate right)
		{
			return left > right || left == right;
		}

		public static bool operator <(ShortDate left, ShortDate right)
		{
			if (left.Year != right.Year)
			{
				return left.Year < right.Year;
			}

			if (left.Month != right.Month)
			{
				return left.Month < right.Month;
			}

			return left.Day < right.Day;
		}

		public static bool operator <=(ShortDate left, ShortDate right)
		{
			return left < right || left == right;
		}

		#endregion // Operators

		#region Overriden Methods

		public override bool Equals(object obj)
		{
			ShortDate other = (ShortDate)obj;
			return Year == other.Year && Month == other.Month && Day == other.Day;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		#endregion // Overriden Methods

		// ToInt32
        // ToUInt32

        public DateTime GetDateTime()
        {
            return new DateTime(Year, Month, Day);
        }
    }
}
